Does anyone know what the purpose of the above syntax is?
Here is the context:
Return val for (_, val) in someList
What does the underscore achieve?
Thanks!
You must be logged in to post. Please login or register an account.
The underscore signals that it's not of any interest, just ignore it.
someList clearly is a list of tuples, and you're only interested in the 2nd value in the tuple, calling it val, and the first value you need to unpack to a variable, but it's put to an underscore to signal to anyone reading the code that it's not going to be used.
-Harrison 8 years ago
You must be logged in to post. Please login or register an account.